package com.ebai.product.management.repository.system;

import java.util.List;

import javax.persistence.Table;
import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.ebai.product.management.model.entity.RoleAuth;

@Repository
@Table(name="role_auth")
@Qualifier("roleAuthRepository")
public interface RoleAuthRepository extends CrudRepository<RoleAuth, String>, JpaSpecificationExecutor<RoleAuth>{
	
	@Query(nativeQuery = true,value = "select t.auth_pid from t_global_role_auth t "
    		+ "where t.role_pid = :rolePid ")
    public List<Object> selectAuthsByRoleid(@Param("rolePid") String rolePid);
	
	@Modifying
    @Transactional
	@Query(" delete from RoleAuth s where s.rolePid=:rolePid ")
	void deleteRoleAuthByRoleid(@Param("rolePid") String rolePid);
}
